# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

from enum import Enum, _EnumDict
import sys

def gen_binance_futures_enum_types(typename, value_list):
  if sys.version_info >= (3, 9, 2):
    return Enum(typename, dict(zip(value_list, range(len(value_list)))))    
  enum_dict = _EnumDict()
  for value in value_list:
    enum_dict[value] = value
  cls = type(typename, (Enum,), enum_dict)
  return cls


BinanceFuturesOrderStatus = gen_binance_futures_enum_types("OrderStatus",
                                                           [
                                                               "NEW",
                                                               "PARTIALLY_FILLED",
                                                               "FILLED",
                                                               "CANCELED",
                                                               "REJECTED",
                                                               "EXPIRED",
                                                           ])

BinanceFuturesOrderStatus2 = gen_binance_futures_enum_types(
    "OrderStatus",
    [
        "NEW",
        "PARTIALLY_FILLED",
        "FILLED",
        "CANCELED",
        "REPLACED",
        "STOPPED",
        "REJECTED",
        "EXPIRED",
        "NEW_INSURANCE",  # Liquidation with Insurance Fund
        "NEW_ADL",  # Counterparty Liquidation
    ])

BinanceFuturesExecutionType = gen_binance_futures_enum_types(
    "ExecutionType",
    [
        "NEW",
        "PARTIAL_FILL",
        "FILL",
        "CANCELED",
        "REJECTED",
        "REPLACED",
        "CALCULATED",  # Liquidation Execution
        "EXPIRED",
        "TRADE",
        "RESTATED",
    ])

BinanceFuturesOrderType = gen_binance_futures_enum_types("OrderTypes", [
    "LIMIT",
    "MARKET",
    "STOP",
])

BinanceFuturesOrderSide = gen_binance_futures_enum_types("OrderSide", [
    "BUY",
    "SELL",
])

BinanceFuturesTimeInForce = gen_binance_futures_enum_types("TimeInForce", [
    "GTC",
    "IOC",
    "FOK",
    "GTX",
])
